﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Data;
using Quiz_Builder.Model;
using Quiz_Builder.View.TestTypes;
using Quiz_Builder.ViewModel.TestTypes;

namespace Quiz_Builder.Converters
{
    class TestTypeToViewConverter:IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null && value is TestType)
            {
                var view = new UserControl();
                switch ((TestType)value)
                {
                    case TestType.TrueFalse:
                        view = new TrueFalseTestView();
                        view.DataContext = new TrueFalseTestViewModel();
                        break;
                    case TestType.Matching:
                        view = new MatchingTestView();
                        view.DataContext = new MatchingTestViewModel();
                        break;
                    case TestType.MultipleChoice:
                        view = new MultipleChoiceTestView();
                        view.DataContext = new MultipleChoiceTestViewModel();
                        break;
                    case TestType.MultipleResponse:
                        view = new MultipleResponseTestView();
                        view.DataContext = new MultipleResponseTestViewModel();
                        break;
                    case TestType.FreeText:
                        view = new FreeTextTestView();
                        view.DataContext = new FreeTextTestViewModel();
                        break;
                }
                //if (value.Equals(TestType.TrueFalse))
                    //view = new TrueFalseTestView();
                return view;
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
